package com.syy.homework1;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class HomeWorkMapper extends Mapper<LongWritable, Text, HomeWork, NullWritable> {
    private HomeWork homeWork = new HomeWork();
    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, HomeWork, NullWritable>.Context context) throws IOException, InterruptedException {
        String s = value.toString();
        String[] split = s.split(" ");

        homeWork.setName(split[0]);
        homeWork.setNumber(Integer.parseInt(split[1]));
        homeWork.setNumbers("");

        context.write(homeWork, NullWritable.get());
    }
}
